@extends('admin.layout.layout', ['row' => @$page])

@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
        </div>

        <div>
            <div>
                <table class="table text-nowrap bt-table d-none">
                    <thead>
                    <tr class="order_column text-center">
                        <th data-column="id">{{ ts('sequence') }}</th>
                        <th data-column="system_type_value">{{ ts('TBXT') }}</th>
                        <th data-column="cycle_value">{{ ts('TBPC') }}</th>
                        <th data-column="sync_status_value">{{ ts('TBZT') }}</th>
                        <th data-column="synced_at">{{ ts('TBSJ') }}</th>
                        <th data-column="status_value">{{ ts('STATUS') }}</th>
                        <th style="width:270px">{{ ts('OPERATIONS') }}</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $k => $v)
                        <tr class="item-list text-center">
                            <td>{{ $v->id }}</td>
                            <td>{{ $v->system_type_value }}</td>
                            <td>{{ @$v->cycle_value }}</td>
                            <td>{{ @$v->sync_status_value }}</td>
                            <td>{{ @$v->synced_at }}</td>
                            <td>{{ @$v->status_value }}</td>
                            <td  class="fixed-td text-center" style="width:270px">
                                @if ($v->status == \App\Models\WarrantySync::STATUS_ENABLE)
                                    <a class="btn btn-success btn-sm" href='' onclick="updateStatus({{$v->id}},2)">{{\App\Models\WarrantySync::$status[\App\Models\WarrantySync::STATUS_DISABLE]}}</a>
                                @else
                                    <a class="btn btn-success btn-sm" href='' onclick="updateStatus({{$v->id}},1)">{{\App\Models\WarrantySync::$status[\App\Models\WarrantySync::STATUS_ENABLE]}}</a>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <div class="row my-3">
                {{--<div class="col-auto">
                    <label style="cursor: pointer"><input type="checkbox" class="icheck_all" data-ele=".roll_icheck"><span class="ml-2">{{ ts('SELECTALL') }}</span></label>
                    <span class="btn btn-primary ml-3" onclick="deleteAlliCheck('.roll_icheck', '/admin/distributor/deletes')">{{ ts('delete') }}</span>
                </div>--}}
                <div class="col">
{{--                    {{ $data->appends(request()->input())->links() }}--}}
                </div>
            </div>
        </div>


    </div>


@endsection

@section('script')
    <script>
        $(document).ready(function () {
            $('.table.bt-table').bootstrapTable({
                fixedColumns: true,
                fixedNumber: 1,
                fixedRightNumber: 1,
            }).removeClass('d-none')
        })
        function updateStatus(id,status){
            $.ajax({
                url: '/admin/sync/update_status?id=' + id+'&status='+status,
                data: {},
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    console.log(data)
                    if (data.code != 0) {
                        toastr.error(data.msg)
                        return false;
                    } else {
                        toastr.success("操作成功")
                        window.location.reload()
                    }

                }
            });
        }
    </script>
@endsection